<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">

        <ui:define name="body">
            <script  type="text/javascript" src="media/js/autoNumeric.js"></script>

            <div class="section">
                <h1>Relatórios de Vendas</h1>
                <h:form id="reportForm">
                    <p:growl id="msg"  life="3000"/>

                    <div class="container_24 clearfix">

                        <div class="clear" />
                        <p:panel header="Filtro" styleClass="grid_24 clearfix " >

                            <p:outputLabel value="Empreendimento:" for="enterpriseAutocomplete" styleClass="grid_4 enterpriseLabel" />
                            <p:autoComplete styleClass="grid_18"  value="#{managerReportSale.enterprise}" id="enterpriseAutocomplete" completeMethod="#{managerReportSale.autocompleteEnterprise}"  
                                            var="p" dropdown="true" itemLabel="#{p.name}" itemValue="#{p}" converter="#{autocompleteconverter}" forceSelection="true">

                            </p:autoComplete>
                            <div class="clear-both"/>

                            <p:outputLabel value="Corretor:" styleClass="grid_4 enterpriseLabel" for="correctorAutocomplete" />
                            <p:autoComplete styleClass="#{managerReportSale.isCorrector ? 'grid_13' : 'grid_18'}" disabled="#{managerReportSale.usesCurrentUser}" value="#{managerReportSale.corrector}" id="correctorAutocomplete" completeMethod="#{managerReportSale.autocompleteCorrector}"  
                                            var="p" dropdown="true" itemLabel="#{p.name}" itemValue="#{p}" 
                                            converter="#{autocompleteconverter}" forceSelection="true">
                                <p:ajax event="itemSelect"  />
                            </p:autoComplete>

                            <p:selectBooleanCheckbox itemLabel="Utilizar corretor atual" value="#{managerReportSale.usesCurrentUser}" styleClass="selectUserActual" style="margin-left: 30px; margin-top: 5px" rendered="#{managerReportSale.isCorrector}">  
                                <p:ajax update="correctorAutocomplete" process="@this" listener="#{managerReportSale.loadCorrector()}"/>  
                            </p:selectBooleanCheckbox>  
                            <div class="clear"/>

                            <p:outputLabel value="De:" styleClass="grid_4"  />
                            <p:calendar showOn="button" styleClass="grid_5"                                                                       
                                        pattern="dd/MM/yyyy"
                                        value="#{managerReportSale.startDate}"/>
                            <p:outputLabel value="Até:" styleClass="grid_3"  />
                            <p:calendar showOn="button" styleClass="grid_5"                                                                       
                                        pattern="dd/MM/yyyy"
                                        value="#{managerReportSale.endDate}"/>
                            <div class="clear"/>

                            <div class="buttonAction">
                                <p:commandButton value="Gerar Balanço" 
                                                 action="#{managerReportSale.balanceSales()}"
                                                 update="@form"
                                                 process="@form"
                                                 icon="ui-icon-clipboard" 
                                                 />
                                <p:commandButton value="Lista de Vendas" 
                                                 action="#{managerReportSale.reportSales()}"
                                                 update="@form"
                                                 process="@form"
                                                 icon="ui-icon-clipboard" 
                                                 />
                            </div>

                        </p:panel>

                    </div>

                </h:form>
            </div>
        </ui:define>
    </ui:composition>
</html>
